﻿using System.Collections.Generic;
using Bdcs.Application.Mappers.Dto;
using Bdcs.Application.Services.IServices;
using Bdcs.Core.Entity;
using Furion.DynamicApiController;
using Microsoft.AspNetCore.Mvc;

namespace Bdcs.Application.Controllers
{
    [ApiDescriptionSettings("用户管理接口@101")]
    public class UserController : IDynamicApiController
    {
        private readonly IUserService _userService;

        public UserController(IUserService userService)
        {
            _userService = userService;
        }

        /// <summary>
        /// 用户管理分页
        /// </summary>
        /// <param name="pageIndex"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public PagedList<UserDto> List(int pageIndex,int pageSize)
        {
            return _userService.List(pageIndex, pageSize);
        }

        /// <summary>
        /// 新增/更新用户
        /// </summary>
        /// <param name="userInput"></param>
        /// <returns></returns>
        public int Add(UserInput userInput)
        {
            return _userService.Add(userInput);
        }

        /// <summary>
        /// 判断userID是否存在
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public int GetIsExist(string userId)
        {
            return _userService.GetIsExist(userId);
        }
        
        /// <summary>
        /// 更改用户所属公司
        /// </summary>
        /// <param name="userid">用户id</param>
        /// <param name="companyIds">公司id(用逗号隔开)</param>
        /// <returns></returns>
        public int ChaneUserCompany(string userid,string companyIds)
        {
            return _userService.UpdateCompanyChoose(userid, companyIds);
        }

        public Adv_UserInfoMod Delete(string userId)
        {
            return _userService.Delete(userId);
        }
    }
}